<?php

/**
 * MVM_MALL 网上商店系统  关联商品追加
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-02-27 $
 * $Id: goods_set.inc.php www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL') || !defined('IN_ADMINCP')) exit('Access Denied');

if(!$ps_ac) $ps_ac = "desc";
if($ps_or == "price" and $ps_ac) {
	$order_sql = " order by goods_sale_price $ps_ac ";
} elseif($ps_or == "stock" and $ps_ac) {
	$order_sql = " order by goods_stock $ps_ac ";
} elseif($ps_or == "date" and $ps_ac) {
	$order_sql = " order by register_date $ps_ac ";
} else {
	$order_sql = " order by uid desc ";
}
if($ps_ac == "desc") $ps_ac = "asc"; else $ps_ac = "desc";
$act=='largess'?$search_sql = " goods_class = '2' ":$search_sql = " goods_class = '0' ";
if($ps_cate) $search_sql .= " and goods_category = '$ps_cate'";

if($amode == "detail_search") {
	if($ps_duse != "1") {
		if($ps_min) { $search_sql .= " and goods_sale_price >= '$ps_min' "; }
		if($ps_max) { $search_sql .= " and goods_sale_price <= '$ps_max' "; }
	}

	if($ps_subject) { $search_sql .= " and goods_name like '%$ps_subject%' "; }
	if($ps_category) {
		$list = $db->fetch_array($db->query("select * from {$tablepre}category_table where category_name like '%$ps_category%' "));
		$ps_ss = $list[category_id];
		$search_sql .= " and goods_category = '$ps_ss' ";
	}
	if($ps_code)	{ $search_sql .= " and goods_code like '%$ps_code%' "; }
	if($ps_company) { $search_sql .= " and goods_company like '%$ps_company%' "; }
	if($ps_origin)	{ $search_sql .= " and goods_origin like '%$ps_origin%' "; }
	if($ps_brand)	{ $search_sql .= " and goods_brand like '%$ps_brand%' "; }
	if($ps_content) { $search_sql .= " and goods_main like '%$ps_content%' "; }
	if(isnum($ps_stock))	{ $search_sql .= " and goods_stock <= '$ps_stock' "; }
	$total_count = $db->counter("{$tablepre}goods_table", "$search_sql", "*");

} else {
	$total_count = $db->counter("{$tablepre}goods_table", "$search_sql", "*");
}

if($search_sql) $search_sql = "where ".$search_sql;

$list_num = 50;
$page_num = 10;

$total_page	= @ceil($total_count / $list_num);

if ($ps_page == "") $ps_page = 1;
$from_record = ($ps_page - 1) * $list_num;
$counter = $total_count - (($ps_page - 1) * $list_num);
$query = "select * from {$tablepre}goods_table $search_sql $order_sql limit $from_record, $list_num";

$result = $db->query($query);

if(!$ps_page)	$ps_page = "1";
if($ps_page == "1") {
	$stock_result = $db->query("select * from {$tablepre}goods_table where goods_class = '0' and goods_stock < '5' order by goods_stock asc limit 0, 30");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<meta http-equiv="Content-Language" content="zh-cn"/>
<meta name="author" content="南南 || www.mvmmall.com"/>
<meta name="copyright" content="MVM mall关注购物未来"/>
<meta name="keywords" content="MVM mall关注购物未来"/>
<meta name="description" content="做最好最快最漂亮的网上商店系统、网店系统平台，软件PHP程序，商城模板，提供全系列电子商务、网络购物软件,在线购物、网上购物软件均提供在线下载和免费试用"/>
<meta content="电子商务、网店、网络购物、网上购物、在线购物、网上商城、网上商店、免费软件、网上开店、网上支付"/>
<link rel="stylesheet" type="text/css" href="images/admincp/public.css" media="all"/>
<title>mvmmall</title>
<script type="text/javascript">
function admin_set_add(form_name){
	var add_list = "";
	var i = "";
	var m = "";
	if (confirm('被选择了的商品\n销售商品追加吗?\n')) {
		for(i=0; i< uid_check_form.elements.length; i++) {
			m = uid_check_form.elements[i];
			if ((m.name != "uid_check") && (m.type=="checkbox") && m.checked == true) {
				add_list = add_list+uid_check_form.elements[i].value;
			}
		}
		opener.document.mvmmall.goods_add_goods.value = opener.document.mvmmall.goods_add_goods.value+add_list;
		window.close();
		return true;
	}
	return false;
}
function admin_set_largess(form_name){
	var add_list = "";
	var i = "";
	var m = "";
	if (confirm('被选择了的商品\n赠送商品追加吗?\n')) {
		for(i=0; i< uid_check_form.elements.length; i++) {
			m = uid_check_form.elements[i];
			if ((m.name != "uid_check") && (m.type=="checkbox") && m.checked == true) {
				add_list = add_list+uid_check_form.elements[i].value;
			}
		}
		opener.document.mvmmall.goods_largess = opener.document.mvmmall.goods_largess.value+add_list;
		window.close();
		return true;
	}
	return false;
}

function select_all(){
	for(var i=0;i<uid_check_form.elements.length;i++){
		var m = uid_check_form.elements[i];
		if((m.name!="uid_check")&&(m.type=="checkbox")){
			m.checked=true;
		}
	}
}

function select_del(){
	for(var i=0;i<uid_check_form.elements.length;i++) {
		var m=uid_check_form.elements[i];
		if((m.name!="uid_check")&&(m.type=="checkbox")){
			m.checked=false;
		}
	}
}
</script>
</head>
<body>
<div style="text-align: center;">
<form action="admincp.php?module=goods" method="post" name="uid_check_form">
<input type="hidden" name="amode" value="all_modify"/>
<input type="hidden" name="ps_url" value="admincp.php?module=goods"/>
<input type="hidden" name="ps_cate" value="<?php echo $ps_cate?>"/>
<table border="0" cellpadding="5" cellspacing="1" width="650" bgcolor="#808080">
<tr>
<td colspan="7" bgcolor="#b0b0b0" height="3"></td>
</tr>
<tr>
<td bgcolor="#e0e0e0" colspan="7"><b>商品管理组套菜单追加</b></td>
</tr>
<tr>
<td width="30" align="center" bgcolor="#f0f0f0"><b></b></td>
<td width="50" align="center" bgcolor="#f0f0f0"><b>NO</b></td>
<td width="210" align="center" bgcolor="#f0f0f0"><b>商品名</b></td>
<td width="130" align="center" bgcolor="#f0f0f0"><b>商品分类</b></td>
<td width="80" align="center" bgcolor="#f0f0f0"><a href="admincp.php?module=goods?ps_or=price&ps_ac=<?php echo $ps_ac?>"><b>商城价格</b></a></td>
<td width="70" align="center" bgcolor="#f0f0f0"><a href="admincp.php?module=goods?ps_or=stock&ps_ac=<?php echo $ps_ac?>"><b>库存数量</b></a></td>
<td width="80" align="center" bgcolor="#f0f0f0"><a href="admincp.php?module=goods?ps_or=date&ps_ac=<?php echo $ps_ac?>"><b>登记日期</b></a></td>
</tr>
<?php
while($list = $db->fetch_array($result)) {
$list[register_date] = date("Y-m-d",$list[register_date]);

	if($list[approval_date] == "0") {
		$show_bgcolor = "bgcolor=\"#DEF7FF\"";
	}
	else {
		$show_bgcolor = "bgcolor=\"#ffffff\"";
	}

	$query = "select * from {$tablepre}category_table where category_id = '$list[goods_category]'";
	$result2 = $db->query($query);
	$list2 = $db->fetch_array($result2);

?>
<tr <?php echo $show_bgcolor?>>
<td align="center"><input type="checkbox" name="uid_check[]" value="<?php echo "$list[uid]/"; ?>"></td>
<td align="center"><?php echo $list[uid]?></td>
<td align="left"><?php echo $list[goods_name]?></td>
<td align="center"><?php echo $list2[category_name]?></td>
<td align="right"><?php echo make_price_format($list[goods_sale_price])?>元</td>
<td align="right"><?php echo $list[goods_stock]?></td>
<td align="center"><?php echo $list[register_date]?></td>
</tr>
<?php
}
?>
<tr>
<td bgcolor="#f0f0f0" colspan="7">
<input type="button" onclick="select_all();" value="全部选择" class="button"/>
<input type="button" onclick="select_del();" value="全部不选" class="button"/>　　　　　
被选择了的商品 
<?php if ($act=='largess'){?>
<input type="button" value="赠送商品追加 " onclick="admin_set_largess(uid_check_form)" class="button"/>
<?}else {?>
<input type="button" value="销售商品追加 " onclick="admin_set_add(uid_check_form)" class="button"/>
<?php }?>
</td>
</tr>
<tr>
<td colspan="7" bgcolor="#f0f0f0" align="center">
<?php
$rewrite =0;
$page_list = page_list($ps_page, $total_page, $list_num, $page_num, "admincp.php?module=goods_set&amode=$amode&ps_or=$ps_or&ps_ac=$ps_ac&ps_cate=$ps_cate&ps_min=$ps_min&ps_max=$ps_max&ps_subject=$ps_subject&ps_category=$ps_category&ps_code=$ps_code&ps_company=$ps_company&ps_origin=$ps_origin&ps_brand=$ps_brand&ps_content=$ps_content&ps_stock=$ps_stock&ps_page=");
if ($page_list != "") { echo "&nbsp;".$page_list."&nbsp;"; }
?>
</td>
</tr>
</table>
</form>
<p></p>
<form name="search_form" action="admincp.php?module=goods_set" method="post">
<input type="hidden" name="amode" value="detail_search"/>
<table border="0" cellpadding="5" cellspacing="1" width="650" bgcolor="#808080">
<tr>
<td colspan="7" bgcolor="#b0b0b0" height="3"></td>
</tr>
<tr>
<td bgcolor="#e0e0e0" colspan="7"><b>商品详细检索</b></td>
</tr>
<tr>
<td bgcolor="#f0f0f0"><b>商品价格范围</b></td>
<td bgcolor="#ffffff" colspan="3"><input type="text" name="ps_min" value="<?php echo $ps_min?>" size="20" maxlength="100" class="text"/> ~ <input type="text" name="ps_max" value="<?php echo $ps_max?>" size="20" maxlength="100" class="text"/> <input type="checkbox" name="ps_duse" value="1"<?php if($ps_duse == "1") echo " checked='true'"; ?>/> 价格除外时(检查)</td>
</tr>
<tr>
<td width="15%" bgcolor="#f0f0f0"><b>产品名称</b></td>
<td width="35%" bgcolor="#ffffff"><input type="text" name="ps_subject" value="<?php echo $ps_subject?>" size="20" maxlength="100" class="text"/></td>
<td width="15%" bgcolor="#f0f0f0"><b>分类名</b></td>
<td width="35%" bgcolor="#ffffff"><input type="text" name="ps_category" value="<?php echo $ps_category?>" size="20" maxlength="100" class="text"/></td>
</tr>
<tr>
<td bgcolor="#f0f0f0"><b>商品编码</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_code" value="<?php echo $ps_code?>" size="20" maxlength="100" class="text"/></td>
<td bgcolor="#f0f0f0"><b>制造公司</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_company" value="<?php echo $ps_company?>" size="20" maxlength="100" class="text"/></td>
</tr>
<tr>
<td bgcolor="#f0f0f0"><b>原产地</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_origin" value="<?php echo $ps_origin?>" size="20" maxlength="100" class="text"/></td>
<td bgcolor="#f0f0f0"><b>品牌</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_brand" value="<?php echo $ps_brand?>" size="20" maxlength="100" class="text"/></td>
</tr>
<tr>
<td bgcolor="#f0f0f0"><b>产品详细信息</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_content" value="<?php echo $ps_content?>" size="20" maxlength="100" class="text"/></td>
<td bgcolor="#f0f0f0"><b>数量(以下)</b></td>
<td bgcolor="#ffffff"><input type="text" name="ps_stock" value="<?php echo $ps_stock?>" size="20" maxlength="100" class="text"/></td>
</tr>
<tr>
<td bgcolor="#ffffff" colspan="4" align="center"><input type="button" value="开始检索" onclick="this.form.submit()" class="button"/></td>
</tr>
</table>
</form>
</div>
</body>
</html>
